from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template

from bookmarks.views import *
from bookmarks.feeds import *

import os.path

sitemedia = os.path.join(
  os.path.dirname(__file__), 'sitemedia'
)

feeds = {
  'recent': RecentBookmarks,
  'user': UserBookmarks,
}

urlpatterns = patterns('',
    # Example:
    # (r'^django_bookmarks/', include('django_bookmarks.foo.urls')),

    ## Admin interface
    (r'^admin/', include('django.contrib.admin.urls')),
    
    ## Ajax
    (r'^ajax/tag/autocomplete/$', ajax_tag_autocomplete),
    
    ## Friends
      (r'^friends/(\w+)/$', friends_page),
      (r'^friend/add/$', friend_add),
      (r'^friend/invite/$', friend_invite),
      (r'^friend/accept/(\w+)/$', friend_accept),
    
    ## Browsing
      (r'^$', main_page), ## The main page for our bookmarks project.
      (r'^user/(\w+)/$', user_page),
      (r'tag/([^\s]+)/$', tag_page),
      (r'tag/$', tag_cloud_page),
      (r'^search/$', search_page),
      
    ## Session and user management  
      (r'^register/$', register_page),
      (r'^register/success/$', direct_to_template,
          {'template': 'registration/register_success.html' }),
      (r'^login/$', 'django.contrib.auth.views.login'),
      (r'^logout/$', logout_page),
      
    ## For serving static files such as css, javascript, end so on.
      (r'^sitemedia/(?P<path>.*)$', 'django.views.static.serve',
          {'document_root': sitemedia }),
    
    ## Account management
      (r'save/$', bookmark_save_page),
      
    ## Feeds
      (r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed',
         {'feed_dict': feeds}),
         
    ## Localization
      (r'^i18n/', include('django.conf.urls.i18n')),
      

)

